Fix malloc handling with newer gcc (>= 5.2)
authorRob Browning <rlb@defaultvalue.org>
Mon, 5 Sep 2016 19:39:00 +0000 (14:39 -0500)
committerRob Browning <rlb@defaultvalue.org>
Mon, 5 Sep 2016 19:39:25 +0000 (14:39 -0500)
Add 0021-Emacs-should-work-with-gcc-5.2-and-newer.patch to incorporate
the relevant upstream code.  Thanks to Aurelien Jarno for reporting the
problem and backporting the fix.

1  2 
debian/.git-dpm
debian/patches/0021-Emacs-should-work-with-gcc-5.2-and-newer.patch
debian/patches/series

diff --cc debian/.git-dpm
index e1e5b3053b7ebbe72564dbbf7573ccb68655f927,0000000000000000000000000000000000000000..3f35bda492075471f137425e5128e5cb54212142
mode 100644,000000..100644
--- /dev/null
@@@ -1,8 -1,0 +1,8 @@@
- d4a257411a7c23c2ed75c3e163243fd0e92dc2be
- d4a257411a7c23c2ed75c3e163243fd0e92dc2be
 +# see git-dpm(1) from git-dpm package
++f07b5081dc17404b73acfc9da576d9746d276b7a
++f07b5081dc17404b73acfc9da576d9746d276b7a
 +62bc68f777c532a970566625e315d68bf0ab4eee
 +62bc68f777c532a970566625e315d68bf0ab4eee
 +emacs24_24.5+1.orig.tar.bz2
 +790a17cf600831dd5c36afddb9cb48bc5482e6c9
 +24401779
index 0000000000000000000000000000000000000000,0000000000000000000000000000000000000000..e780d1ffd3359d05ef178858d15cfc3f228b6233
new file mode 100644 (file)
--- /dev/null
--- /dev/null
@@@ -1,0 -1,0 +1,90 @@@
++From f07b5081dc17404b73acfc9da576d9746d276b7a Mon Sep 17 00:00:00 2001
++From: Wolfgang Jenkner <wjenkner@inode.at>
++Date: Sat, 26 Dec 2015 12:12:02 -0800
++Subject: Emacs should work with gcc 5.2 and newer
++
++This patch, backported from upstream by Aurelien Jarno
++<aurel32@debian.org>, has been added:
++
++  Always define gmalloc etc. in src/gmalloc.c
++
++  This is a work-around to prevent the compiler from using semantic
++  knowledge about malloc for optimization purposes.  E.g., gcc 5.2
++  with -O2 replaces most of calloc's definition by a call to calloc;
++  see Bug#22085.
++  * src/gmalloc.c [!HYBRID_MALLOC] (malloc, realloc, calloc)
++  (aligned_alloc, free): Do not undef.  Instead, define these as
++  functions (perhaps renamed to gmalloc etc.) in terms of gmalloc etc.
++
++Origin: backport, commit: 4b1436b702d56eedd27a0777fc7232cdfb7ac4f6
++Bug-Debian: http://bugs.debian.org/833727
++Added-by: Rob Browning <rlb@defaultvalue.org>
++---
++ src/gmalloc.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
++ 1 file changed, 47 insertions(+)
++
++diff --git a/src/gmalloc.c b/src/gmalloc.c
++index cfd39be..9f93b62 100644
++--- a/src/gmalloc.c
+++++ b/src/gmalloc.c
++@@ -49,6 +49,17 @@ extern "C"
++ 
++ #include <stddef.h>
++ 
+++#undef malloc
+++#undef realloc
+++#undef calloc
+++#undef aligned_alloc
+++#undef free
+++#define malloc gmalloc
+++#define realloc grealloc
+++#define calloc gcalloc
+++#define aligned_alloc galigned_alloc
+++#define free gfree
+++#define malloc_info gmalloc_info
++ 
++ /* Allocate SIZE bytes of memory.  */
++ extern void *malloc (size_t size);
++@@ -1747,6 +1758,42 @@ valloc (size_t size)
++   return aligned_alloc (pagesize, size);
++ }
++ 
+++#undef malloc
+++#undef realloc
+++#undef calloc
+++#undef aligned_alloc
+++#undef free
+++
+++void *
+++malloc (size_t size)
+++{
+++  return gmalloc (size);
+++}
+++
+++void *
+++calloc (size_t nmemb, size_t size)
+++{
+++  return gcalloc (nmemb, size);
+++}
+++
+++void
+++free (void *ptr)
+++{
+++  gfree (ptr);
+++}
+++
+++void *
+++aligned_alloc (size_t alignment, size_t size)
+++{
+++  return galigned_alloc (alignment, size);
+++}
+++
+++void *
+++realloc (void *ptr, size_t size)
+++{
+++  return grealloc (ptr, size);
+++}
+++
++ #ifdef GC_MCHECK
++ 
++ /* Standard debugging hooks for `malloc'.
index 902aa8108cf9d338c85981ce9588cc2272027944,0000000000000000000000000000000000000000..4844a1e3695436d3885dabffc845336536cc46f4
mode 100644,000000..100644
--- /dev/null
@@@ -1,20 -1,0 +1,21 @@@
 +0001-Prefer-usr-share-info-emacs-24-over-usr-share-info.patch
 +0002-Run-debian-startup-and-set-debian-emacs-flavor.patch
 +0003-Remove-files-that-appear-to-be-incompatible-with-the.patch
 +0004-Adjust-documentation-references-for-Debian.patch
 +0005-Modify-the-output-of-version-to-indicate-Debian-modi.patch
 +0006-Look-for-NEWS-in-order-to-find-etc-rather-than-GNU.patch
 +0007-Don-t-try-to-build-src-macuvs.h-via-IVD_Sequences.tx.patch
 +0008-Emacs-won-t-assume-grep-supports-GREP_OPTIONS.patch
 +0009-Emacs-should-no-longer-hang-during-large-yanks.patch
 +0010-ELF-unexec-Correct-section-header-index.patch
 +0011-ELF-unexec-Tidy-code.patch
 +0012-ELF-unexec-Merge-Alpha-and-MIPS-COFF-debug-handling.patch
 +0013-ELF-unexec-Symbol-table-patching.patch
 +0014-ELF-unexec-_OBJC_-symbols-in-bss-sections.patch
 +0015-ELF-unexec-R_-_NONE-relocs.patch
 +0016-ELF-unexec-Drive-from-PT_LOAD-header-rather-than-sec.patch
 +0017-ELF-unexec-Don-t-insert-a-new-section.patch
 +0018-src-unexelf.c-NEW_PROGRAM_H-Remove-unused-macro-Bug-.patch
 +0019-ELF-unexec-align-section-header.patch
 +0020-Emacs-should-show-GTK-icons-again.patch
++0021-Emacs-should-work-with-gcc-5.2-and-newer.patch